const { createConnection } = require('mysql2');

// 数据库连接配置
const connection = createConnection({
  host: 'localhost',
  user: 'root',
  password: '123456',
  database: 'nestjs'
});

// 查询策略表
connection.query('SELECT * FROM casbin_policies', (error, results) => {
  if (error) {
    console.error('查询出错:', error);
    return;
  }
  
  console.log('Casbin策略:');
  console.log('ID\tptype\tv0\t\tv1\t\t\tv2\t\tv3\tv4\tv5');
  console.log('-------------------------------------------------------------------------------------');
  results.forEach(row => {
    console.log(`${row.id}\t${row.ptype}\t${row.v0 || ''}\t\t${row.v1 || ''}\t\t${row.v2 || ''}\t\t${row.v3 || ''}\t${row.v4 || ''}\t${row.v5 || ''}`);
  });
  
  connection.end();
});